﻿using System.ComponentModel.DataAnnotations;
using System.Web.UI.WebControls;
using easyVal.ValidationAttributes;
using easyVal.Web;
using easyVal.Web.Demo.Entities;
using easyVal.Web.Extensions;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace easyVal.Test.Web.Extensions
{

    [TestClass]
    public class AddValidationAttributeTestClass
    {
              

        [TestMethod]
        public void AddValidateionAttributeTest()
        {
            TextBox textBox = new TextBox();

            textBox.AddValidationAttributeEasy("required", "field can't be blank.");

            string attr = textBox.Attributes["validate"];
            Assert.IsTrue(attr == "{required:true,messages:{required:'field can\\'t be blank.'}}");

        }

        [TestMethod]
        public  void ValidationMapping()
        {
            ClientModelValidation map = new ClientModelValidation(typeof (Employee));

            TextBox txtLastName = new TextBox();
            map.AddValidation(txtLastName, "LastName");

            TextBox txtEmail = new TextBox();
            map.AddValidation(txtEmail, "Email");

            TextBox txtDesiredSalary = new TextBox();
            map.AddValidation(txtDesiredSalary, "DesiredSalary");
            
        }

    }
}
